<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets"
	   xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:a4j="http://richfaces.org/a4j"
	   xmlns:rich="http://richfaces.org/rich" 
      xmlns:composite="http://java.sun.com/jsf/composite">

<!-- INTERFACE -->
<composite:interface>
	<composite:attribute name="sistema" />
	<composite:attribute name="sistemas" />
	<composite:attribute name="pendencias" />
	<composite:attribute name="bean" />
</composite:interface>

<!-- IMPLEMENTATION -->
<composite:implementation>
	<rich:panel id="pnlSistema" styleClass=".form" header="Registro de sistemas" headerClass="header" columnClasses="label, none">

	<h:panelGrid columns="4"  >
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Nome:" /></div></h:panelGroup>
		<h:inputText id="nomeSistema" value="#{cc.attrs.sistema.nome}"   style="width:100px;" />
	
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Data criação:" /></div></h:panelGroup>
       	<rich:calendar for="dataCriacaoSistema" value="#{cc.attrs.sistema.dataCriacao}" datePattern="dd/MM/yyyy" mode="ajax" boundaryDatesMode="scroll" >
       		<f:convertDateTime type="date" dateStyle="short" locale="pt_BR" timeZone="America/Sao_Paulo" pattern="dd/MM/yyyy"/>  
   		</rich:calendar>  

		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Versão:" /></div></h:panelGroup>
		<h:inputText id="versaoSistema" value="#{cc.attrs.sistema.versao}"   style="width:100px;" />
	
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Matrícula:" /></div></h:panelGroup>
		<h:inputText id="matriculaSistema" value="#{cc.attrs.sistema.matricula}" style="width:100px;" />
	</h:panelGrid>
	
	<h:panelGrid columns="2" >
		<h:panelGroup><div style="text-align:right; width:70px;"><h:outputLabel value="Descricao:" /></div></h:panelGroup>
		<h:inputTextarea id="descricaoSistema" value="#{cc.attrs.sistema.descricao}" rows="4" cols="80" />
	</h:panelGrid>
	
	
	<h:panelGrid columns="4" >
		<a4j:commandButton action="#{cc.attrs.bean.novoSistema}" value="Novo" styleClass="register" 
			title="Clique para criar um novo sistema" style="width:100px; height:22px;"/>
		<a4j:commandButton action="#{cc.attrs.bean.exclua}" value="Excluir" 
				render="listaSistemas" styleClass="register" title="Clique para excluir" style="width:100px; height:22px;">
			<f:setPropertyActionListener target="#{cc.attrs.bean.idSistema}" value="#{cc.attrs.sistema.id}" />
		</a4j:commandButton>
		<a4j:commandButton action="#{cc.attrs.bean.registrar}" 	value="Registrar" styleClass="register" 
				title="Clique para incluir/alterar" style="width:100px; height:22px;" render="lstRegristraPendencias, lstSistemas"/>
		<a4j:commandButton action="#{cc.attrs.bean.registrarComPendencias}" value="Registrar COM PENDÊNCIAS" styleClass="register" 
				title="Clique para incluir/alterar o sistema atual" style="width:200px; height:22px;" render="lstRegristraPendencias, lstSistemas"/>
	</h:panelGrid>
	
	<h:messages styleClass="messages" errorClass="invalid" infoClass="valid" warnClass="warning" globalOnly="true" />
</rich:panel>
	
<rich:collapsiblePanel id="lstSistemas" header="Sistemas" headerClass="header" title="Click to expand/collapse">
   <h:panelGroup rendered="#{empty cc.attrs.sistemas}">
      <em>Nenhum sistema registrado.</em>
   </h:panelGroup>
   <rich:dataTable var="item" value="#{cc.attrs.sistemas}" rendered="#{not empty cc.attrs.sistemas}" style="width : 100%">
	   <rich:column>
			<a4j:commandLink action="#{cc.attrs.bean.buscaSistema}" styleClass="no-decor" render="sistemaPanel" > Visualiza
				<f:setPropertyActionListener target="#{cc.attrs.bean.idSistema}" value="#{item.id}" />
			</a4j:commandLink>
           </rich:column>
		<rich:column>
			<f:facet name="header">Id</f:facet>  #{item.id}
           </rich:column>
		<rich:column>
			<f:facet name="header">Sistema</f:facet>  #{item.nome}
           </rich:column>
		<rich:column>
			<f:facet name="header">Descrição</f:facet> #{item.descricao}
           </rich:column>
		<rich:column>
			<f:facet name="header">Data criação</f:facet> #{item.dataCriacao}
            </rich:column>
	</rich:dataTable>
</rich:collapsiblePanel>	

	<rich:collapsiblePanel id="lstRegristraPendencias" header="O projeto tem as seguintes pendencias:" headerClass="header" title="Clique para expandir/fechar	">
		<h:panelGroup rendered="#{empty cc.attrs.pendencias}">
			<em>Nenhuma pendencia registrada.</em>
		</h:panelGroup>
		<rich:dataTable var="item" value="#{cc.attrs.pendencias}" rendered="#{not empty cc.attrs.pendencias}" style="width : 100%">
			<rich:column>
				<f:facet name="header">Data</f:facet>  #{item.dataPendencia}
           </rich:column>
			<rich:column>
				<f:facet name="header">Status</f:facet> #{item.status}
           </rich:column>
			<rich:column>
				<f:facet name="header">Ocorrência</f:facet> #{item.pendencia}
           </rich:column>
		</rich:dataTable>
	</rich:collapsiblePanel>

</composite:implementation>
</html>